package com.lmy.androidcustomview.touch

import android.content.Context
import android.util.AttributeSet
import android.util.Log
import android.view.MotionEvent
import android.view.ViewGroup
import android.widget.LinearLayout

/**
 * @author
 * @功能:
 * @Creat 2/12/21 7:21 PM
 * @Compony 465008238@qq.com
 */
class TouchLayout(context: Context, attrs: AttributeSet) : LinearLayout(context, attrs) {
    //拦截
    override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
        Log.e("TouchLayout", "onInterceptTouchEvent")
        return true
    }

    //消费 只有当onInterceptTouchEvent返回为true的时候onTouchEvent才会被调用
    override fun onTouchEvent(event: MotionEvent?): Boolean {
        Log.e("TouchLayout", "onTouchEvent")
        return super.onTouchEvent(event)
    }

    //用于调度是否拦截或者直接调用自身或者子View的onTouchEvent
    //也就是super.dispatchTouchEvent(ev)
    //这个我们一般不需要重写
    override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
        return super.dispatchTouchEvent(ev)
    }
}